import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

//引入插件
import AutoImport from "unplugin-auto-import/vite";
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
  base:"./",
  plugins: [
    vue(),
    //配置插件
    AutoImport({
      imports: ["vue", "vue-router"],
      dts: "./auto-imports.d.js", // 生成 `auto-import.d.ts` 全局声明
      resolvers: [ElementPlusResolver()]
    }),
    Components({
      resolvers: [ElementPlusResolver()],
      dts: "./components.d.js", // 生成 `auto-import.d.ts` 全局声明
    })
  ],
  resolve: {
    // 配置路径别名
    alias: {
      "@": resolve(__dirname, "./src"),
      "@style": resolve(__dirname, "./src/assets/style"),
      '@components': resolve(__dirname, "./src/components"),
      "@views": resolve(__dirname, "./src/views"),
      "@store": resolve(__dirname, "./src/store"),
      "@router": resolve(__dirname, "./src/router"),
    },
  },
  // server: {
  //   hmr: true,
  // },
})
